reed-solomon-erasure
Rust implementation of Reed-Solomon erasure coding
WASM builds are also available, see section WASM usage below for details
This is a port of BackBlaze's Java implementation, Klaus Post's Go implementation, and Nicolas Trangez's Haskell implementation.
Version 1.X.X
copies BackBlaze's implementation, and is less performant as there were fewer places where parallelism could be added.
Version >= 2.0.0
copies Klaus Post's implementation. The SIMD C code is copied from Nicolas Trangez's implementation with minor modifications.
See Notes and License section for details.
WASM usage
See here for details
Rust usage
Add the following to your Cargo.toml
for the normal version (pure Rust version)
[]
= "4.0"
or the following for the version which tries to utilise SIMD
[]
= { = "4.0", = "simd-accel" }
and the following to your crate root
extern crate reed_solomon_erasure;
Example
extern crate reed_solomon_erasure;
use ReedSolomon;
// or use the following for Galois 2^16 backend
// use reed_solomon_erasure::galois_16::ReedSolomon;
Benchmark it yourself
You can test performance under different configurations quickly (e.g. data parity shards ratio, parallel parameters) by cloning this repo: https://github.com/darrenldl/rse-benchmark
rse-benchmark
contains a copy of this library (usually a fully functional dev version), so you only need to adjust main.rs
then do cargo run --release
to start the benchmark.
Performance
Version 1.X.X
, 2.0.0
do not utilise SIMD.
Version 2.1.0
onward uses Nicolas's C files for SIMD operations.
Machine: laptop with Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (max 2.70GHz) 2 Cores 4 Threads
Below shows the result of one of the test configurations, other configurations show similar results in terms of ratio.
Configuration | Klaus Post's | >= 2.1.0 && < 4.0.0 | 2.0.X | 1.X.X |
---|---|---|---|---|
10x2x1M | ~7800MB/s | ~4500MB/s | ~1000MB/s | ~240MB/s |
Versions >= 4.0.0
have not been benchmarked thoroughly yet
Changelog
Contributions
Contributions are welcome. Note that by submitting contributions, you agree to license your work under the same license used by this project as stated in the LICENSE file.
Credits
Library overhaul and Galois 2^16 backend
Many thanks to the following people for overhaul of the library and introduction of Galois 2^16 backend
WASM builds
Many thanks to Nazar Mokrynskyi @nazar-pc for submitting his package for WASM builds
He is the original author of the files stored in wasm
folder. The files may have been modified by me later.
AVX512 support
Many thanks to @sakridge for adding support for AVX512 (see PR #69)
build.rs improvements
Many thanks to @ryoqun for improving the usability of the library in the context of cross-compilation (see PR #75)
Testers
Many thanks to the following people for testing and benchmarking on various platforms
-
Laurențiu Nicola @lnicola (platforms: Linux, Intel)
-
Roger Andersen @hexjelly (platforms: Windows, AMD)
Notes
Code quality review
If you'd like to evaluate the quality of this library, you may find audit comments helpful.
Simply search for "AUDIT" to see the dev notes that are aimed at facilitating code reviews.
Implementation notes
The 1.X.X
implementation mostly copies BackBlaze's Java implementation.
2.0.0
onward mostly copies Klaus Post's Go implementation, and copies C files from Nicolas Trangez's Haskell implementation.
The test suite for all versions copies Klaus Post's Go implementation as basis.
License
Nicolas Trangez's Haskell Reed-Solomon implementation
The C files for SIMD operations are copied (with no/minor modifications) from Nicolas Trangez's Haskell implementation, and are under the same MIT License as used by NicolasT's project
TL;DR
All files are released under the MIT License